﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConAppCore.Json
{
    public class JsonStu
    {
        private readonly int _guid = 123;
        public int Guid
        {
            get { return _guid; }
        }

        public readonly int Guid2 = 567;


        public char Ch { get; set; }
        public char? Ch2 { get; set; }

        public byte B1 { get; set; }

        public sbyte SB1 { get; set; }

        public Int16 I16 { get; set; }

        public UInt16 UI16 { get; set; }

        public Int32 I32 { get; set; }
        public Int32? I322 { get; set; }

        public UInt32 UI32 { get; set; }

        public Int64 I64 { get; set; }

        public UInt64 UI64 { get; set; }


        public float F { get; set; }

        public double DB { get; set; }

        public decimal DC { get; set; }

        public bool IsDeleted { get; set; }
        public bool? IsDeleted2 { get; set; }

        public string Name { get; set; }

        public DateTime BirDateTime { get; set; }
        public DateTime? BirDateTime2 { get; set; }

        public DateTimeOffset BirDateTimeOffset { get; set; }
        public DateTimeOffset? BirDateTimeOffset2 { get; set; }

        //public DateOnly BirDateOnly { get; set; }
        //public DateOnly? BirDateOnly2 { get; set; }

        //public TimeOnly BirTimeOnly { get; set; }
        //public TimeOnly? BirTimeOnly2 { get; set; }

        public string Grae { get; set; }

        public Sexs Sex1 { get; set; }

        public Sexs? Sex2 { get; set; }

        public List<Int32> I32List { get; set; }
        public List<Int32> I32List2 { get; set; }

        public JsonAddr Add { get; set; }

        public JsonAddr Add2 { get; set; }

        public List<JsonAddr> ObjectList { get; set; }

        public List<JsonAddr> ObjectList2 { get; set; }

        public List<JsonAddr[]> ObjectList3 { get; set; }

        public Dictionary<string, int> Dic1 { get; set; }

        public Dictionary<string, Dictionary<string, int>> Dic12 { get; set; }

        public Dictionary<string, Dictionary<string, JsonAddr>> Dic13 { get; set; }

        public Dictionary<string, int> Dic2 { get; set; }

        public Dictionary<string, JsonAddr> Dic3 { get; set; }

        public Dictionary<string, JsonAddr[]> Dic4 { get; set; }

        public Dictionary<int, string> Dic5 { get; set; }

        public Dictionary<int, JsonAddr> DicObj6 { get; set; }

        /// <summary>
        /// key直接调用.ToString()得到,非基础数据类型不支持
        /// </summary>
        //public Dictionary<JsonAddr, JsonAddr> Dic5 { get; set; }




        public JsonStu()
        {

        }

        private static Random _rnd = null;
        public static JsonStu CreateRandomDemo()
        {
            if (_rnd == null)
            {
                _rnd = new Random();
            }

            string speStr = "{成都\"a:b\\c,c}";
            //speStr = "成都abc";

            JsonStu jsonStu = new JsonStu()
            {
                Ch = 'a',
                B1 = (byte)_rnd.Next(byte.MinValue, byte.MaxValue),
                SB1 = (sbyte)_rnd.Next(sbyte.MinValue, sbyte.MaxValue),
                I16 = (short)_rnd.Next(short.MinValue, short.MaxValue),
                UI16 = (ushort)_rnd.Next(ushort.MinValue, ushort.MaxValue),
                I32 = (int)_rnd.Next(int.MinValue, int.MaxValue),
                UI32 = (uint)_rnd.Next(0, int.MaxValue),
                I64 = (long)_rnd.Next(int.MinValue, int.MaxValue),
                UI64 = (ulong)_rnd.Next(0, int.MaxValue),
                F = (float)_rnd.Next(sbyte.MinValue, sbyte.MaxValue),
                DB = (double)_rnd.Next(sbyte.MinValue, sbyte.MaxValue),
                DC = (decimal)_rnd.Next(sbyte.MinValue, sbyte.MaxValue),
                IsDeleted = true,
                Name = $"{speStr}_{_rnd.Next(int.MinValue, int.MaxValue)}",
                BirDateTime = DateTime.Now,
                BirDateTimeOffset = DateTimeOffset.Now,
                //BirDateOnly = DateOnly.Parse(DateTime.Now.ToString("d")),
                //BirTimeOnly = TimeOnly.Parse(DateTime.Now.ToString("T")),
                Grae = null,
                Sex1 = Sexs.Woman,
                Sex2 = null,
                I32List = new List<int>() { 31, 32, 33 },
                Add = new JsonAddr()
                {
                    BigAdd = speStr,
                    SmallAdd = $"{{新都}}){{_rnd.Next(int.MinValue, int.MaxValue)}}",
                    NestedAdd = new JsonAddr
                    {
                        BigAdd = $"四川{_rnd.Next(int.MinValue, int.MaxValue)}",
                        SmallAdd = $"云南{_rnd.Next(int.MinValue, int.MaxValue)}",
                        NestedAdd = new JsonAddr()
                        {
                            BigAdd = $"四川2{_rnd.Next(int.MinValue, int.MaxValue)}",
                            SmallAdd = $"云南2{_rnd.Next(int.MinValue, int.MaxValue)}",
                            NestedAdd = null
                        }
                    }
                },
                ObjectList = new List<JsonAddr>()
                {
                    new JsonAddr()
                    {
                        BigAdd = $"abc{_rnd.Next(int.MinValue, int.MaxValue)}",
                        SmallAdd = $"xx新{_rnd.Next(int.MinValue, int.MaxValue)}"
                    },
                    new JsonAddr()
                    {
                        BigAdd = speStr,
                        SmallAdd = $"都dd{_rnd.Next(int.MinValue, int.MaxValue)}"
                    },
                    new JsonAddr()
                    {
                        BigAdd = speStr,
                        SmallAdd = $"新都{_rnd.Next(int.MinValue, int.MaxValue)}dd"
                    },
                },
                ObjectList3 = new List<JsonAddr[]>()
                {
                    new JsonAddr[]
                    {
                        new JsonAddr(){BigAdd = $"abc11{_rnd.Next(int.MinValue, int.MaxValue)}",SmallAdd = $"新11{_rnd.Next(int.MinValue, int.MaxValue)}"},
                        new JsonAddr(){BigAdd = $"abc12{_rnd.Next(int.MinValue, int.MaxValue)}",SmallAdd = $"新12{_rnd.Next(int.MinValue, int.MaxValue)}"},
                    },
                    new JsonAddr[]
                    {
                        new JsonAddr(){BigAdd = $"abc21{_rnd.Next(int.MinValue, int.MaxValue)}",SmallAdd = $"新21{_rnd.Next(int.MinValue, int.MaxValue)}"},
                        new JsonAddr(){BigAdd = $"abc22{_rnd.Next(int.MinValue, int.MaxValue)}",SmallAdd = $"新22{_rnd.Next(int.MinValue, int.MaxValue)}"},
                    }
                },
                Dic1 = new Dictionary<string, int>() { { $"aa{_rnd.Next(int.MinValue, int.MaxValue)}", 123 }, { $"bb{_rnd.Next(int.MinValue, int.MaxValue)}", 456 } },
                Dic12 = new Dictionary<string, Dictionary<string, int>>()
                {
                   { $"aa{_rnd.Next(int.MinValue, int.MaxValue)}",new Dictionary<string, int>() { { $"aa{_rnd.Next(int.MinValue, int.MaxValue)}", 123 }, { $"b{_rnd.Next(int.MinValue, int.MaxValue)}", 456 } } },
                   { $"b{_rnd.Next(int.MinValue, int.MaxValue)}", new Dictionary<string, int>() { { $"aa{_rnd.Next(int.MinValue, int.MaxValue)}", 123 }, { $"b{_rnd.Next(int.MinValue, int.MaxValue)}", 456 } }},
                },
                Dic13 = new Dictionary<string, Dictionary<string, JsonAddr>>()
                {
                   { $"aa{_rnd.Next(int.MinValue, int.MaxValue)}", new Dictionary<string, JsonAddr>() { { $"aa{_rnd.Next(int.MinValue, int.MaxValue)}", new JsonAddr() { BigAdd = "abc11", SmallAdd = "{新}11" } }, { $"b{_rnd.Next(int.MinValue, int.MaxValue)}", new JsonAddr() { BigAdd = "abc12", SmallAdd = "{新}12" } } } },
                   { $"b{_rnd.Next(int.MinValue, int.MaxValue)}", new Dictionary<string, JsonAddr>() { { $"aa{_rnd.Next(int.MinValue, int.MaxValue)}", new JsonAddr() { BigAdd = "abc21", SmallAdd = "{新}21" } }, { $"b{_rnd.Next(int.MinValue, int.MaxValue)}", new JsonAddr() { BigAdd = "abc22", SmallAdd = "{新}22" } } }},
                },
                Dic2 = null,
                Dic3 = new Dictionary<string, JsonAddr>()
                {
                    { "cc",  new JsonAddr() { BigAdd = "abc", SmallAdd = "{新}" } },
                    { "ddd", new JsonAddr() { BigAdd = "abc2", SmallAdd = "{新}2" } },
                },
                Dic4 = new Dictionary<string, JsonAddr[]>()
                {
                    { $"aa{_rnd.Next(int.MinValue, int.MaxValue)}",new JsonAddr[] {  new JsonAddr(){BigAdd = "abc11",SmallAdd = "{新}11"},new JsonAddr(){BigAdd = "abc12",SmallAdd = "{新}12"}} },
                    { $"b{_rnd.Next(int.MinValue, int.MaxValue)}", new JsonAddr[] { new JsonAddr(){BigAdd = "abc21",SmallAdd = "{新}21"},new JsonAddr(){BigAdd = "abc22",SmallAdd = "{新}22"} }},
                },
                Dic5 = new Dictionary<int, string>()
                {
                     {456 ,"intKey"},
                    {325,"中国" },
                },
                DicObj6 = new Dictionary<int, JsonAddr>()
                {
                    { 11,  new JsonAddr() { BigAdd = "abc", SmallAdd = "{新}" } },
                    { 22, new JsonAddr() { BigAdd = "abc2", SmallAdd = "{新}2" } },
                }
                //Dic5 = new Dictionary<JsonAddr, JsonAddr>()
                //{
                //    {new JsonAddr() { Add1 = "abc", Add2 = "{新}" }, new JsonAddr() { Add1 = "abc", Add2 = "{新}" } },
                //    { new JsonAddr() { Add1 = "abc2", Add2 = "{新}2" }, new JsonAddr() { Add1 = "abc2", Add2 = "{新}2" } },
                //}
            };

            return jsonStu;
        }


        public static JsonStu CreateDemo()
        {
            string speStr = "{成都\"a:b\\c,c}";
            //speStr = "成都abc";

            JsonStu jsonStu = new JsonStu()
            {
                Ch = 'a',
                B1 = 10,
                SB1 = -10,
                I16 = -11,
                UI16 = 11,
                I32 = -12,
                UI32 = 12,
                I64 = -13,
                UI64 = 13,
                F = -14.065F,
                DB = 15.55063D,
                DC = 16.66789M,
                IsDeleted = true,
                Name = speStr,
                BirDateTime = DateTime.Parse("2000-04-05 12:25:36"),
                BirDateTimeOffset = DateTime.Parse("2000-04-06 12:25:36"),
                //BirDateOnly = DateOnly.Parse("2000-04-06"),
                //BirTimeOnly = TimeOnly.Parse("12:25:36"),
                Grae = null,
                Sex1 = Sexs.Woman,
                Sex2 = null,
                I32List = new List<int>() { 31, 32, 33 },
                Add = new JsonAddr()
                {
                    BigAdd = speStr,
                    SmallAdd = "{新都}",
                    NestedAdd = new JsonAddr
                    {
                        BigAdd = "四川",
                        SmallAdd = "云南",
                        NestedAdd = new JsonAddr()
                        {
                            BigAdd = "四川2",
                            SmallAdd = "云南2",
                            NestedAdd = null
                        }
                    },
                    NesteObjList = new List<JsonAddr>()
                    {
                        new JsonAddr()
                        {
                            BigAdd = "nestedBigAdd",
                            SmallAdd = "nestedSmallAdd"
                        },
                        new JsonAddr()
                        {
                            BigAdd = speStr,
                            SmallAdd ="nestedSmallAdd2"
                        },
                    }
                },
                ObjectList = new List<JsonAddr>()
                {
                    new JsonAddr()
                    {
                        BigAdd = "abc",
                        SmallAdd = "{新}"
                    },
                    new JsonAddr()
                    {
                        BigAdd = speStr,
                        SmallAdd = "{都}"
                    },
                    new JsonAddr()
                    {
                        BigAdd = speStr,
                        SmallAdd = "{新都}"
                    },
                },
                ObjectList3 = new List<JsonAddr[]>()
                {
                    new JsonAddr[]
                    {
                        new JsonAddr(){BigAdd = "abc11",SmallAdd = "{新}11"},
                        new JsonAddr(){BigAdd = "abc12",SmallAdd = "{新}12"},
                    },
                    new JsonAddr[]
                    {
                        new JsonAddr(){BigAdd = "abc21",SmallAdd = "{新}21"},
                        new JsonAddr(){BigAdd = "abc22",SmallAdd = "{新}22"},
                    }
                },
                Dic1 = new Dictionary<string, int>() { { "aa1", 123 }, { "bb2", 456 } },
                Dic12 = new Dictionary<string, Dictionary<string, int>>()
                {
                   { "aa3",new Dictionary<string, int>() { { "aa4", 123 }, { "bb5", 456 } } },
                   { "bb6", new Dictionary<string, int>() { { "aa7", 123 }, { "bb8", 456 } }},
                },
                Dic13 = new Dictionary<string, Dictionary<string, JsonAddr>>()
                {
                   { "aa9", new Dictionary<string, JsonAddr>() { { "aa10", new JsonAddr() { BigAdd = "abc11", SmallAdd = "{新}1ff1" } }, { "bb789", new JsonAddr() { BigAdd = "abc12hfgh", SmallAdd = "{新}12ggg" } } } },
                   { "bb12", new Dictionary<string, JsonAddr>() { { "aa13", new JsonAddr() { BigAdd = "abc21", SmallAdd = "{新}2ggg1" } }, { "bb978", new JsonAddr() { BigAdd = "abc22ddc", SmallAdd = "{新}22jjkj" } } }},
                },
                Dic2 = null,
                Dic3 = new Dictionary<string, JsonAddr>()
                {
                    { "cc14",  new JsonAddr() { BigAdd = "abc9", SmallAdd = "{新}7/" } },
                    { "ddd15", new JsonAddr() { BigAdd = "abc2", SmallAdd = "{新}2" } },
                },
                Dic4 = new Dictionary<string, JsonAddr[]>()
                {
                    { "aa16",new JsonAddr[] {  new JsonAddr(){BigAdd = "abc11p",SmallAdd = "{新}11t"},new JsonAddr(){BigAdd = "abc12kkk",SmallAdd = "{新}12444"}} },
                    { "bb17", new JsonAddr[] { new JsonAddr(){BigAdd = "abc21f",SmallAdd = "{新}2177"},new JsonAddr(){BigAdd = "abc2dd2",SmallAdd = "{新}2222244"} }},
                },
                Dic5 = new Dictionary<int, string>()
                {
                     {456 ,"intKey"},
                    {325,"中国" },
                },
                DicObj6 = new Dictionary<int, JsonAddr>()
                {
                    { 11,  new JsonAddr() { BigAdd = "abc", SmallAdd = "{新}" } },
                    { 22, new JsonAddr() { BigAdd = "abc2", SmallAdd = "{新}2" } },
                }
                //Dic5 = new Dictionary<JsonAddr, JsonAddr>()
                //{
                //    {new JsonAddr() { Add1 = "abc", Add2 = "{新}" }, new JsonAddr() { Add1 = "abc", Add2 = "{新}" } },
                //    { new JsonAddr() { Add1 = "abc2", Add2 = "{新}2" }, new JsonAddr() { Add1 = "abc2", Add2 = "{新}2" } },
                //}
            };

            return jsonStu;
        }
    }

}
